$(function(){
	// 获取本地存储对象 
	var localStorage = window.localStorage;
	var confirmMID = localStorage.getItem("key");
	$.post("http://localhost:8081/study/getAllRole",{
		confirmMID:confirmMID
	},function(data){
		if(data.success){
			var list = data.list;
			var roleInnerHtml = "";
			$.each(list, function(index,data) {
				roleInnerHtml += "<option value='"+data.id+"'>"+data.remark+"</option>"
			});
			$("#roleId").html(roleInnerHtml)
		}else{
			console.log(data.message)
		}
	})
	
	$("#submit").click(function(){
		var username = $("#username").val();
		var passwords = $("#password").val();
		var roleId = $("#roleId").val();
 		$.post("http://localhost:8081/study/createUser",{
 			username:username,
 			password:passwords,
 			roleId:roleId
 		},function(data){
 			console.log(data);
 			if(data.success){
 				alert(data.message);
 				window.location.href ="html/index.html"
 			}else{
 				alert(data.message);
 			}
 		})
	})
	
	//禁用form表单自定义action提交功能
	$(document).ready(function() {
		$("form").submit(function(e) {
			e.preventDefault();
			console.log("Submit prevented");
		});
	});
})
